<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
         // [2, 6, 77, 52, 25, 7] 排序后 [2, 6, 7, 25, 52, 77]
         let arr = [2, 6, 77, 52, 25, 7];
         function bubble(arr){
            for(let i = 1;i<arr.length;i++){
                for(let j= 0;j<arr.length-i;j++){
                    if(arr[j]>arr[j+1]){
                        let num=arr[j];
                        arr[j]=arr[j+1];
                        arr[j+1]=num;
                    }
                }
            }
         }
         bubble(arr);
         for(let impt of arr){
             console.log(impt)
         }
        
    </script>
</body>
</html>